﻿using System;
using Family.Core.Exceptions;

namespace Family.Core
{
    public static class Check
    {
        public static void Require(bool assertion, Exception inner)
        {
            if (inner == null)
            {
                throw new ArgumentNullException("inner", "Inner exception must be not null!");
            }

            if (!assertion)
            {
                throw new PreconditionException("Precondition failed!", inner);
            }
        }

        /// <summary>
        /// Precondition check - should run regardless of preprocessor directives.
        /// </summary>
        /// <param name="assertion">if set to <c>true</c> passes, otherwise throws exception.</param>
        /// <param name="inner">The inner exception.</param>
        //public static void RequireWithRedirectException(bool assertion, Exception inner)
        //{
        //    if (inner == null)
        //    {
        //        throw new ArgumentNullException("inner", "Inner exception must be not null!");
        //    }

        //    if (!assertion)
        //    {
        //        throw new PreconditionByRoutingException("Precondition by routing failed!", inner);
        //    }
        //}
    }
}
